package _0_语法._4_循环._1_单循环;

public class _3_求1加2加3加到n小于8888的最大正整数n {

    public static void main(String[] args) {

        int sum = 0;
        int count; // 循环执行次数

        for (count = 1; ;count++){
            sum = sum + count;
            if(sum > 8888){
                sum = sum - count;
                count--;
                break;
            }
        }
        System.out.println("sum = " + sum);
        System.out.println("n = " + count);
    }
}
